/**
 * 返回结构如下所示
 */
export interface JsonResult {
  code: number
  message: string
  data: object | any | null
}

/**
 * 成功返回结构
 * @param data
 * @param message
 * @param code
 */
export function ok(
    data: object | any | null,
    msg: string = 'ok',
    code: number = 200
): JsonResult {
  return {
    code: code,
    message: msg,
    data: data
  }
}
// 失败返回值
export function fail(msg: string = 'fail', code: number = -1): JsonResult {
  return {
    code: code,
    message: msg,
    data: null
  }
}
